// pages/rechargecard/pending/index.js
var a = getApp(), t = a.requirejs("core"), e = a.requirejs("biz/order");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:''
  },
  all(e){
    var that =this;
    var ids = that.data.ids;
    console.log(ids,555)
    t.get('member/rechargeagree', { id: ids }, function (e) {
      wx.showModal({
        title: '友情提示',
        content: '已全部同意',
        showCancel: false,
        success(res) {
          wx.showToast({
            title: '加载中',
            icon: 'loading'
          }),that.getlist()
        }
      });
    })
  },
  agree(e){
    var that = this;
    var id = e.currentTarget.dataset.id;
    t.get('member/rechargeagree', { id: id}, function (e) {
     
      wx.showModal({
        title: '友情提示',
        content: '已成功发送',
        showCancel: false,
        success(res) {
          wx.showToast({
            title: '加载中',
            icon: 'loading'
          }),that.getlist()
        }
      });
      // wx.navigateTo({
      //   url: '/pages/rechargecard/repeatCollar/index',
      // })
    })
    console.log(id,454)
  },
  refuse(e) {
    var that = this;
    var id = e.currentTarget.dataset.id;
    t.get('member/rechargerefuse', { id: id }, function (e) {
      console.log(4545)
      wx.showModal({
        title: '友情提示',
        content: '已拒绝',
        showCancel: false,
        success(res) {
          wx.showToast({
            title: '加载中',
            icon: 'loading'
          }),that.getlist()
        }
      });
      // wx.navigateTo({
      //   url: '/pages/rechargecard/repeatCollar/index',
      // })
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    var that =this;
    wx.showToast({
      title: '加载中',
      icon:'loading'
    }),that.getlist()
  },
  getlist(){
    var that = this;
    t.get('member/pendinglist', '', function (e) {
      
      console.log(e, 8888)
      var ids = [];
      e.data.forEach(function (item, index) {
        // console.log(item.id);
        ids.push(item.id)
        that.setData({
          ids: ids,
        })
      });
      that.setData({
        list: e.data
      })
      wx.hideToast();
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})